let questionsApp = new Vue({
   el:'#questionsApp',
   data:{
       questions:[
           {
               statusText:'已解决',
               statusClass:'badge_success',
               title:'这是第一个问题',
               content:'很<b>严肃</b>的提出第一个问题',
               tags:[
                   {jd: 8,name:'java基础'},
                   {jd: 12,name:'spring'},
                   {jd: 15,name:'springBoot'}
               ],
               userNickName:'天下第一',
               hits:'826',
               createdTimeText:'8小时之前',
               tagImage:'/img/tags/8.jpg'
           },
           {
               statusText:'未解决',
               statusClass:'badge_success',
               title:'这是第二个问题',
               content:'idontno',
               tags:[
                   {jd: 8,name:'javaEE'},
                   {jd: 12,name:'mysql'},
               ],
               userNickName:'天下第二',
               hits:'757',
               createdTimeText:'1小时之前',
               tagImage:'/img/tags/10.jpg'
           },
       ],
       pageInfo:[]
   },
    methods: {
        loadMyQuestions: function (page) {
            if (!page || page<1)
                page=1;
            $.ajax({
                url: '/api/v1/questions/my',
                data:'page='+page,
                success: function (json) {
                    // json.data.list
                    let data = json.data;
                    let questions = data.list;
                    let statusTexts = ['未回复', '未解决', '已解决'];
                    let statusClasses = ['badge-warning', 'badge-info', 'badge-success'];
                    for (let i = 0; i < questions.length; i++) {
                        questions[i].statusText = statusTexts[questions[i].status];
                        questions[i].statusClass = statusClasses[questions[i].status];
                        questions[i].tagImage = '/img/tags/' + questions[i].tags[0].id + '.jpg';
                        questions[i].createdTimeText = getCreatedTimeText(questions[i].createdTime);

                    }

                    questionsApp.questions = questions;
                    questionsApp.pageInfo = data;
                }
            });
        }
    },
    created: function () {
        this.loadMyQuestions();
    }
});